<?php

class Admini_TransationController extends Uuch_ManageController {

      public function init() {
            $this->appendCss('/css/home/warehouse.css');
            $this->appendCss('/admins/css/common.css');
            $this->appendScript('/admins/js/jquery/jquery-1.7.2.min.js')->appendScript('/js/jquery.validate.min.js')->appendScript('/js/messages_cn.js')->appendScript('/js/uuch.js');
            parent::init();
            $this->view->type = "autotask";
      }

      public function indexAction() {
            $this->setTitle('扫描订单');
            $this->view->conse = 0;
            $shipItem = Application_Model_shipType::getAll();
            $this->view->shipAll = $shipItem;
            if ($this->isPost()) {
                  $userItem = new Application_Model_Transa();
                  $userItem->companyID = $this->getSafeParam('comname');
                  $userItem->transationCS = str_replace("\r", '', str_replace("\n", '', nl2br($this->getSafeParam('barcode2'))));
                  if ($userItem->transationCS) {
                        $userItem->datetime = $this->now();
                        $userItem->operator = Uuch_Util::getUserNikeName();
                        $userItem->save();
                        $this->view->conse = $userItem->setOne();
                        $this->view->id = $userItem->id;
                  }
            }
      }

      public function printAction() {
            $pagesize = 30;
            $pageindex = $this->_getParam('start');
            if (!$pageindex) {
                  $pageindex = 0;
            }
            $this->disableLayout();
            $name = $this->_getParam("name");
            $id = $this->_getParam('id');
            $count = $this->_getParam('count');
            $result = Application_Model_Transalist::getFilter($name, $pagesize, $pageindex);

            //给视图传数组
            $this->view->userlist = $result["list"];
            $this->view->userall = $result;
            if ($id) {
                  $result = Application_Model_Transalist::getbyid($id, $pagesize, $pageindex);
                  $this->view->userlist = $result["list"];
                  $this->view->userall = $result;
            }
            if ($count) {
                  $result = Application_Model_Transalist::getbycount($count, $pagesize, $pageindex);
                  $this->view->userlist = $result["list"];
                  $this->view->userall = $result;
            }
      }

      public function listAction() {
            $this->settitle('订单列表');
            //后台管理页，包括分页，和循环输出
            $pagesize = 15;
            $pageindex = $this->_getParam('start');
            if (!$pageindex) {
                  $pageindex = 0;
            }
            $quick = $this->_getParam("quick");
            if ($quick) {
                  $this->view->ma = 1;
            } else {
                  $this->view->ma = 2;
            }
            $result = Application_Model_Transalist::getPageFilter($quick, $pagesize, $pageindex);
            $this->view->trackList = $result["list"];
            if (count($this->view->trackList) == 1) {
                  $this->view->ma = 0;
            }
            $this->view->trackAll = $result;
            $this->view->quick = $quick;
      }

}
